package cn.t222.ch04;

import cn.t222.ch04.config.MyTest;
import cn.t222.ch04.pojo.Author;
import cn.t222.ch04.pojo.Book;
import cn.t222.ch07.starter.MyStarter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Controller
public class DemoController {
//    @GetMapping("/tologin")
//    public String tologin() {
//        return "login";//templates/login.html
//    }
    @Autowired
    private MyStarter myStarter;

    @GetMapping("/starter")
    @ResponseBody
    @MyTest(value = "这是测试注解")
    public Object start() {
        return myStarter.print();
    }

    @GetMapping("/demo")
    @ResponseBody
    public Object hello(@ModelAttribute("b") Book book,@ModelAttribute("a") Author author) {
        return book.getName() +":::" + author.getName() +"-" + author.getAge();
    }
    @GetMapping("/test")
    public Object test() {
        int i =  1 / 0;
        return  "hello";
    }
}
